/*
@file	Polygon.cpp
@author	Saume
*/

#include "Polygon.h"

Polygon::Polygon(): 
x(0.0f), 
y(0.0f) {

}

Polygon::Polygon(float xVal, float yVal):
x(xVal),
y(yVal) {

}

Polygon::Polygon(const Vector* const v) :
x(v->x),
y(v->y) {

}

/*
Moves the polygon by a given vector offset.
Does not consider Z axis.
*/
void Polygon::MoveBy(float xVal, float yVal) {
	x += xVal;
	y += yVal;
	return;
}

/*
Moves the polygon by a given x and y offset.
*/
void Polygon::MoveBy(const Vector* const v) {
	MoveBy(v->x, v->y);
	return;
}

/*
Displays the coordinates of the polygon in the console.
*/
void Polygon::Display() const {
	std::cout << "(" << x << ", " << y << ")";
	return;
}

Polygon::~Polygon() {

}

/*
Returns true if both polygons are at the same position.
*/
bool operator==(const Polygon& p1, const Polygon& p2) {
	float dx = p2.GetX() - p1.GetX();
	float dy = p2.GetY() - p1.GetY();
	dx = fabs(dx);
	dy = fabs(dy);

	return dx <= EPSILON_DBL && dy <= EPSILON_DBL;
}